﻿function view_onSizing() {
    
    if (event.width > 200) event.width = 200;
    else if (event.width < 130) event.width = 130;

    // 234 min 367 max
    if (event.height > 800) event.height = 800;
    else if (event.height < 235) event.height = 235;
    
    options.putValue("width",event.width);
    options.putValue("height",event.height);

}

function view_onDock() {
    isDocked = true;
}

function view_onUndock() {
    isDocked = false;
}

function view_onMinimize() {
    isMinimized = true;
}

function view_onRestore() {
    isMinimized = false;
}

function resizeGui() {
    content.width = view.width;
    content.height = view.height;
    
    if (manager) {
    
        manager.resize( content.width, content.height );
        var todoDisplay;
        var doingDisplay;
        var impedDisplay;
        var doneDisplay;
        var available;
        
        available = manager.containerDisplayArea.height - (21+2);
        todoDisplay = Math.floor(available / POST_HEIGHT);
        
        contNum = 2;
        
        available = manager.containerDisplayArea.height - ((21+2)*2) ;
        doingDisplay = Math.floor(available / POST_HEIGHT);
        impedDisplay = Math.floor(doingDisplay / 2);
        if (doingDisplay%2) {
            doingDisplay = impedDisplay+1;
        }
        else {
            doingDisplay = impedDisplay;
        }
    
        doneDisplay = doingDisplay+impedDisplay-1;
        
        var pageSize = manager.containerDisplayArea.width;
        
        todo.resize(0,0,pageSize,todoDisplay);
        todo.posts[0].resize( 2, todo.postItArea.width );
        for (var i = 1; todo.posts[i]; i++) { todo.posts[i].resize( todo.posts[i-1].area.y+todo.posts[i-1].area.height+2, todo.postItArea.width ); }
        
        doing.resize(pageSize*1,0,pageSize,doingDisplay);
        doing.posts[0].resize( 2, doing.postItArea.width );
        for (var i = 1; doing.posts[i]; i++) { doing.posts[i].resize( doing.posts[i-1].area.y+doing.posts[i-1].area.height+2, doing.postItArea.width ); }
        
        impeded.resize(pageSize*1,doing.area.height,pageSize,impedDisplay);
        impeded.posts[0].resize( 2, impeded.postItArea.width );
        for (var i = 1; impeded.posts[i]; i++) { impeded.posts[i].resize( impeded.posts[i-1].area.y+impeded.posts[i-1].area.height+2, impeded.postItArea.width ); }
        
        done.resize(pageSize*2,0,pageSize,doneDisplay);
        done.posts[0].resize( 2, done.postItArea.width );
        for (var i = 1; done.posts[i]; i++) { done.posts[i].resize( done.posts[i-1].area.y+done.posts[i-1].area.height+2, done.postItArea.width ); }
        
        burndown.resize(pageSize*2,done.area.height,pageSize,1);
        
        
        preferences.resize(pageSize*3,0,pageSize,2);
        var padding = Math.floor(  ( pageSize - 122 ) / 2 );
        for (var i = 0; preferences.opt[i]; i++) { preferences.opt[i].button.x = padding; }
        
        colors.resize(pageSize*3, 107, pageSize,2);
        
        
        manager.setPage();
    
    }
}











